package com.lianniu.mgr.productAssess.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.lianniu.mgr.base.BaseResult;
import com.lianniu.mgr.pagination.PaginationInfo;
import com.lianniu.mgr.productAssess.model.AssessDetailVo;
import com.lianniu.mgr.productAssess.service.IAssessDetailService;

@Controller
@RequestMapping("/rest/assessDetail")
public class AssessDetailRestController {

private final static Logger logger = Logger.getLogger(AssessDetailRestController.class);
	
	@Autowired
	private IAssessDetailService assessDetailService;
	
	@RequestMapping(value="/assessDetailList",method={RequestMethod.GET,RequestMethod.POST})
	  public @ResponseBody BaseResult assessDetailList(HttpServletRequest request, AssessDetailVo curVo, PaginationInfo paginationInfo)
	  {
	       logger.info("AssessDetailRestController  assessDetailList begin.");
	       try {
	           
	           logger.info("assessDetailList begin.");          
	           BaseResult baseResult = assessDetailService.selectByAssessDetailForPage(curVo, paginationInfo);
	           logger.info("assessDetailList end.");
	           logger.info("AssessDetailRestController assessDetailList end.");
	           return baseResult;
	       } catch (Exception e) {
	       logger.error("AssessDetailRestController assessDetailList error:" + e.getMessage());
	       logger.error("AssessDetailRestController assessDetailList end.");
	       return BaseResult.exception(e.getMessage());
	     }
	  }
	
	@RequestMapping(value="/selectAssessDetailById",method={RequestMethod.GET,RequestMethod.POST})
	  public @ResponseBody BaseResult selectAssessDetailById(HttpServletRequest request,AssessDetailVo curVo) {
	        logger.info("AssessDetailRestController selectAssessDetailById begin.");
	        try {
	                    
	          BaseResult baseResult = assessDetailService.selectById(curVo);
	          logger.info("selectAssessDetailById end.");
	          logger.info("AssessDetailRestController selectAssessDetailById end.");
	          return baseResult;
	        } catch (Exception e) {
	          logger.error("AssessDetailRestController selectAssessDetailById error:" + e.getMessage());
	          logger.error("AssessDetailRestController selectAssessDetailById end.");
	          return BaseResult.exception(e.getMessage());
	        }
	        
	  } 
	
	@RequestMapping(value = {"/assessDetailDel"}, method = RequestMethod.POST)
	  public @ResponseBody BaseResult assessDetailDel(HttpServletRequest request) {
	      logger.info("AssessDetailRestController assessDetailDel begin.");
	     try {          
	          logger.info("assessDetailDel begin.");
	          BaseResult baseResult = assessDetailService.deleteAssessDetail(request.getParameter("ids").split(","));		
	          logger.info("assessDetailDel baseResult:" + JSON.toJSONString(baseResult));
	          logger.info("assessDetailDel end.");
	          
	          logger.info("AssessDetailRestController assessDetailDel end.");
	          return baseResult;

	    } catch (Exception e) {
	      logger.error("AssessDetailRestController assessDetailDel error:" + e.getMessage());
	      logger.info("AssessDetailRestController assessDetailDel end.");
	      return BaseResult.exception(e.getMessage());
	    }

	  }
	
}
